package com.aef.service;

import java.util.List;

import com.aef.model.TdWeixinUsers;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class WeixinUserService {
	/**
	 * 保存关注用户信息
	 * @param user
	 */
	public void SaveUser(TdWeixinUsers user) {
		user.save();
	}
	/**
	 * 判断openid是否存在
	 * @param openid
	 * @return
	 */
	public boolean JudgeOpenid(String openid){
		List<Record> list = Db.find("select * from td_weixin_users r where r.openid =?" ,openid);
		return list.size()>0?true:false;  
	}
	
	public int UpdateUser(String openid){
		int record=Db.update("update td_weixin_users  set state='1' where openid=?", openid);
		return record;
	}
	/**
	 * 获取用户信息
	 * @param openid
	 * @return
	 */
	public List<Record> getweiuser(String openid){
		List<Record> list = Db.find("select * from td_weixin_users r where r.openid =?" ,openid);
		return list;  
	}
}
